home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / lib / mathlib / libblas / test / second.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  665 b   |  34 lines

  1.  
  2. #include <sys/time.h>
  3. /*  #include <sys/resource.h>  */
  4.  
  5. /* **********************************************************************
  6.  
  7.    give the elapsed wall clock time
  8.  
  9. ********************************************************************** */
  10. float second_()
  11. {
  12.         struct timeval s_val;
  13.     struct timezone s_z;
  14.  
  15.     static long zero_sec = 0;
  16.     static long zero_usec = 0;
  17.     long n_sec, n_usec;
  18.  
  19.         gettimeofday(&s_val, &s_z);
  20.  
  21.     n_sec = s_val.tv_sec;
  22.     n_usec = s_val.tv_usec;
  23.     if( zero_sec == 0 ) {
  24.          zero_sec = n_sec;
  25.         zero_usec = n_usec;
  26.     }
  27.  
  28.     n_sec = n_sec - zero_sec;
  29.     n_usec = n_usec - zero_usec;
  30.  
  31.     return( (float) n_sec +  ( (float) n_usec * 1.0E-6 ) );
  32. }
  33.  
  34.